<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.lgx.right.entity.User"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	User onlineUser = (User)request.getAttribute("onlineUser");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>绑定手机</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<jsp:include page="/page/jsp/member/head.jsp" />
	<script type="text/javascript">
		//保存信息
		function save(){
			
			$('#saveBtn').attr('disabled','disabled');
			var nMobile = escape(escape($('#nMobile').val()));
			var rMobile = escape(escape($('#rMobile').val())); 
			
			//前后号码一致性验证
			if(nMobile == rMobile && mobileExtend(nMobile) == true){
				var url = path +"/member/jBoxUpdateUserMobile.htm?userId="+${onlineUser.getId()}+"&nMobile="+nMobile;
				//执行ajax操作
				$.ajax({
					  url:url,
					  success: function(data) {
						  if(data == "1"){
							  alertBox("修改成功！");
						   }else{
							  alertBox("操作失败！");
						   } 
					  }
				});
			}else{
				alertBox("<font color='red'>手机号码不正确！</font>");
			}
			
		}
		
		
		//手机号码验证
		function mobileExtend(mobile){
			//return /^[1][3-8]+d{9}/.test(mobile) ; 
			return /^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile);
		}
		
		
	</script>
  </head>
  
  <body>
   <div class="right">
	<h1><b>绑定手机</b><span><img src="<%=basePath%>images/right_h1bg2.jpg" width="3" height="29" /></span></h1>
	<div class="ri_main">
	<form id="form" method="post">
		<table width="100%" border="0" cellspacing="1" cellpadding="8" style="background:#d9d9d9;">
		  <tr>
			<td width="10%" align="right" bgcolor="#FFFFFF">原手机号码</td>
		    <td width="40%" align="left" bgcolor="#FFFFFF" align="left"><label for="textfield"></label>
		    	<lable>${onlineUser != null?onlineUser.mobile:'' }</lable>
		    </td>
		  </tr>
		  <tr>
		  	<td width="10%" align="right" bgcolor="#FFFFFF">新手机号码</td>
		    <td width="40%" align="left" bgcolor="#FFFFFF" align="left">
		      <input id="nMobile" name="nMobile" style="width:200px;" />
		    </td>
		  </tr>
		  <tr>
		  	<td width="10%" align="right" bgcolor="#FFFFFF">重复新手机号</td>
		    <td width="40%" align="left" bgcolor="#FFFFFF" align="left">
		    	<input id="rMobile" name="rMobile" style="width:200px;" />
		    </td>
		  </tr>
		  <tr>
		      <td bgcolor="#FFFFFF" colspan="2" style="text-align: center;">
		      	<input type="button" name="button" id="button" onclick="save()" value="保  存" />
		      </td>
		  </tr>
		</table>
	</form>
	</div>
	</div>
  </body>
</html>
